package com.feib.soeasy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;


/**
 * @title (#)ColumnDefinition.java<br>
 * @description 帳單匯入格式欄位定義<br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/11/10 create by Jimmy Liu<br>
 */
@Entity
@Table(name = "COLUMN_DEFINITION")
public class ColumnDefinition extends AuditEntity {

    private static final long serialVersionUID = 8493165200156750462L;
    
    /**
     * PK in Table
     */
    private Long columnDefinitionPk;
    
    /**
     * 
     */
    private FormatDefinition formatDefinition;
    
    /**
     * 表頭欄位/明細欄位
     * True: 表頭
     * else: 明細
     */
    private Boolean header;
    
    /**
     * 資料表欄位名稱
     */
    private String columnName;
    
    /**
     * 資料表欄位表頭名稱
     */
    private String columnTitle;
    
    /**
     * 資料表欄位型態<br>
     * 1. string
     * 2. number
     * 3. date
     */
    private String columnType;
    
    /**
     * 開始位置(從0開始)
     */
    private Integer beginIndex;
    
    /**
     * 結束位置(從0開始)
     */
    private Integer endIndex;
    
    /**
     * 設定為查詢條件<br>
     * True: 是
     * False, Null: 否
     */
    private Boolean query;
    
    /**
     * 設定為顯示欄位<br>
     * True: 是
     * False, Null: 否
     */
    private Boolean display;
    
    /**
     * 必須輸入欄位<br>
     * True: 是
     * False, Null: 否
     */
    private Boolean required;
    
    /**
     * 排序
     */
    private Integer displayIdx;
    
    /**
     * 顯示刪除按鈕
     * 畫面顯示用，不儲存
     */
    private Boolean canDelete;
    
    /**
     * 修改欄位
     * 畫面顯示用，不儲存
     */
    private Boolean canModify;
    
    /**
     * 修改資料位置
     */
    private Boolean cnaModifyLength;
    
    

    
    /**
     * @return the columnDefinitionPk
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="COLUMN_DEF_PK", nullable=false)
    public Long getColumnDefinitionPk() {
        return columnDefinitionPk;
    }

    
    /**
     * @param columnDefinitionPk the columnDefinitionPk to set
     */
    public void setColumnDefinitionPk(Long columnDefinitionPk) {
        this.columnDefinitionPk = columnDefinitionPk;
    }

    
    /**
     * @return the formatDefinition
     */
    @ManyToOne
    @JoinColumn(name="FORMAT_DEF_PK")
    public FormatDefinition getFormatDefinition() {
        return formatDefinition;
    }

    
    /**
     * @param formatDefinition the formatDefinition to set
     */
    public void setFormatDefinition(FormatDefinition formatDefinition) {
        this.formatDefinition = formatDefinition;
    }

    
    /**
     * @return the header
     */
    @Column(name="IS_HEADER", nullable=false)
    public Boolean getHeader() {
        return header;
    }

    
    /**
     * @param header the header to set
     */
    public void setHeader(Boolean header) {
        this.header = header;
    }

    
    /**
     * @return the columnName
     */
    @Column(name="COLUMN_NAME", nullable=false, length=30)
    public String getColumnName() {
        return columnName;
    }

    
    /**
     * @param columnName the columnName to set
     */
    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    
    /**
     * @return the columnTitle
     */
    @Column(name="COLUMN_TITLE", nullable=false, length=40)
    public String getColumnTitle() {
        return columnTitle;
    }

    
    /**
     * @param columnTitle the columnTitle to set
     */
    public void setColumnTitle(String columnTitle) {
        this.columnTitle = columnTitle;
    }

    
    /**
     * @return the columnType
     */
    @Column(name="COLUMN_TYPE", nullable=false, length=1)
    public String getColumnType() {
        return columnType;
    }

    
    /**
     * @param columnType the columnType to set
     */
    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }

    
    /**
     * @return the beginIndex
     */
    @Column(name="BEGIN_INDEX")
    public Integer getBeginIndex() {
        return beginIndex;
    }

    
    /**
     * @param beginIndex the beginIndex to set
     */
    public void setBeginIndex(Integer beginIndex) {
        this.beginIndex = beginIndex;
    }

    
    /**
     * @return the endIndex
     */
    @Column(name="END_INDEX")
    public Integer getEndIndex() {
        return endIndex;
    }

    
    /**
     * @param endIndex the endIndex to set
     */
    public void setEndIndex(Integer endIndex) {
        this.endIndex = endIndex;
    }

    
    /**
     * @return the query
     */
    @Column(name="IS_QUERY")
    public Boolean getQuery() {
        return query;
    }

    
    /**
     * @param query the query to set
     */
    public void setQuery(Boolean query) {
        this.query = query;
    }

    
    /**
     * @return the display
     */
    @Column(name="IS_DISPLAY")
    public Boolean getDisplay() {
        return display;
    }

    
    /**
     * @param display the display to set
     */
    public void setDisplay(Boolean display) {
        this.display = display;
    }


    
    /**
     * @return the required
     */
    @Column(name="IS_REQUIRED")
    public Boolean getRequired() {
        return required;
    }


    
    /**
     * @param required the required to set
     */
    public void setRequired(Boolean required) {
        this.required = required;
    }


    
    /**
     * @return the displayIdx
     */
    @Column(name="DISPLAY_IDX")
    public Integer getDisplayIdx() {
        return displayIdx;
    }


    
    /**
     * @param displayIdx the displayIdx to set
     */
    public void setDisplayIdx(Integer displayIdx) {
        this.displayIdx = displayIdx;
    }


    
    /**
     * @return the canDelete
     */
    @Transient
    public Boolean getCanDelete() {
        if (null == canDelete)
            canDelete = Boolean.TRUE;
        return canDelete;
    }


    
    /**
     * @param canDelete the canDelete to set
     */
    public void setCanDelete(Boolean canDelete) {
        this.canDelete = canDelete;
    }


    
    /**
     * @return the canModify
     */
    @Transient
    public Boolean getCanModify() {
        if (null == canModify)
            canModify = Boolean.TRUE;
        return canModify;
    }


    
    /**
     * @param canModify the canModify to set
     */
    public void setCanModify(Boolean canModify) {
        this.canModify = canModify;
    }


    
    /**
     * @return the cnaModifyLength
     */
    @Transient
    public Boolean getCnaModifyLength() {
        if (null == cnaModifyLength)
            cnaModifyLength = Boolean.TRUE;
        return cnaModifyLength;
    }


    
    /**
     * @param cnaModifyLength the cnaModifyLength to set
     */
    public void setCnaModifyLength(Boolean cnaModifyLength) {
        this.cnaModifyLength = cnaModifyLength;
    }

}
